Build
As usual, let's install app dependencies and then build the app.
Install app dependencies
The following instructions assume that you have installed Cubist.
Let's start by installing the Cubist Node.js SDK and related dependencies.
cd
to the application directory of
your chosen example and language. Then:
- npm
- yarn
npm install
yarn
Build instructions
We run cubist build
from the top-level token bridge app directory.
From the top-level token bridge app directory, we (as usual) run:
- JavaScript
- TypeScript
cubist build
- npm
- yarn
cubist build && npm run build
cubist build && yarn build
ERC20Bridged
is currently configured to run on
Polygon and TokenSender
on Ethereum, but you can change that
easily from the configuration file.
What Cubist generates
When you build
, Cubist generates one directory per target chain within
the build
output directory:
build
├── orm // Bindings for interacting with the contracts
├── ethereum
│ ├── artifacts // Compiled contracts that will run on ethereum
│ │ ├── ...
│ └── contracts // Source files of all original contracts (or ethereum shims)
│ └── ...
└── polygon
├── artifacts // Compiled contracts that will run on polygon
│ ├── ...
└── contracts // Source files of all original contracts (or polygon shims)
Recall that the orm
directory contains the Cubist-generated binding
code that allows us to interface with our contracts.
In build
, Cubist saves:
- The ABIs and other data produced when compiling the contracts with
solc
(within each target'sartifacts
directory) - Original and shim source files (within each target's
contracts
directory). Cubist copies each contract in your contracts directory and puts them here (or replaces them with their shim, if applicable) - The information that lets the off-chain relayer do
its job (in
${ContractName}.bridge.json
files).
The polygon
and ethreum
artifacts
directories both contain
an ERC20Bridged
file and a TokenSender
file; that's because both
contracts are used cross-chain, so they have shim on the chain
that's not their original target. Within the artifacts
directory,
we also see a number of other directories corresponding to code
that we didn't write. For example,
in the polygon/artifacts
directory, we see directories for
ERC20
, IERC20
, and more. This extra data is generated during compilation
because our token bridge contracts require it; for example,
ERC20Bridged
inherits from ERC20
(which it imports from
OpenZepplin via npm
).
In general, you should not modify any of the files in the build
directory. These files are automatically generated, so your changes may get overwritten.